<template>
	<el-drawer :title="titleMap[mode]" v-model="visible" :size="600" append-to-body destroy-on-close @closed="$emit('closed')">
		<el-container>
			<el-main class="nopadding">
				<el-scrollbar>
					<el-row class="drawer-table">
						<el-col :span="24">
							<el-form :model="form" :rules="rules" :disabled="mode==='show'" ref="dialogForm" label-width="80px">
								<el-form-item label="实名论证,与用户表一对一" prop="hyUserId">
									<el-input v-model="form.hyUserId" placeholder="请输入实名论证,与用户表一对一" clearable></el-input>
								</el-form-item>
								<el-form-item label="最后更新时间" prop="updateTime">
									<el-input v-model="form.updateTime" placeholder="请输入最后更新时间" clearable></el-input>
								</el-form-item>
								<el-form-item label="身份证号" prop="idNumber">
									<el-input v-model="form.idNumber" placeholder="请输入身份证号" clearable></el-input>
								</el-form-item>
								<el-form-item label="身份证姓名" prop="identityCardName">
									<el-input v-model="form.identityCardName" placeholder="请输入身份证姓名" clearable></el-input>
								</el-form-item>
								<el-form-item label="论证图片类型 1身份证 2企业营业执照" prop="fileType">
									<el-input v-model="form.fileType" placeholder="请输入论证图片类型 1身份证 2企业营业执照" clearable></el-input>
								</el-form-item>
								<el-form-item label="身份证正面照片" prop="fileUrl1">
									<el-input v-model="form.fileUrl1" placeholder="请输入身份证正面照片" clearable></el-input>
								</el-form-item>
								<el-form-item label="身份证背面照片" prop="fileUrl2">
									<el-input v-model="form.fileUrl2" placeholder="请输入身份证背面照片" clearable></el-input>
								</el-form-item>
								<el-form-item label="手持身份证拍照" prop="fileUrl3">
									<el-input v-model="form.fileUrl3" placeholder="请输入手持身份证拍照" clearable></el-input>
								</el-form-item>
								<el-form-item label="其他" prop="fileUrl4">
									<el-input v-model="form.fileUrl4" placeholder="请输入其他" clearable></el-input>
								</el-form-item>
								<el-form-item label="其他" prop="fileUrl5">
									<el-input v-model="form.fileUrl5" placeholder="请输入其他" clearable></el-input>
								</el-form-item>
								<el-form-item label="审核业务员" prop="shSysUserId">
									<el-input v-model="form.shSysUserId" placeholder="请输入审核业务员" clearable></el-input>
								</el-form-item>
								<el-form-item label="审核时间" prop="shTime">
									<el-input v-model="form.shTime" placeholder="请输入审核时间" clearable></el-input>
								</el-form-item>
								<el-form-item label="0未审核  1审核通过 2审核不通过" prop="shState">
									<el-input v-model="form.shState" placeholder="请输入0未审核  1审核通过 2审核不通过" clearable></el-input>
								</el-form-item>
                            </el-form>
						</el-col>
					</el-row>
				</el-scrollbar>
			</el-main>
			<el-footer>
				<el-button v-if="mode!=='show'" :loading="isSaveing" @click="submit()" type="primary" size="small">保 存</el-button>
				<el-button size="small" @click="visible=false">取 消</el-button>
			</el-footer>
		</el-container>
	</el-drawer>
</template>
<script>
	export default {
		emits: ['success', 'closed'],
		data() {
			return {
				mode: "add",
				titleMap: {
					add: '新增',
					edit: '编辑',
					mode: '实名论证'
				},
				visible: false,
				isSaveing: false,
				//表单数据
				form: {
					hyUserId: "",
					updateTime: "",
					idNumber: "",
					identityCardName: "",
					fileType: "",
					fileUrl1: "",
					fileUrl2: "",
					fileUrl3: "",
					fileUrl4: "",
					fileUrl5: "",
					shSysUserId: "",
					shTime: "",
					shState: "",
				},
				//验证规则
				rules: {
					userName: [
						{required: true, message: '请输入名称'}
					],
					userAge: [
						{pattern: /^[0-9]*$/, message: '年龄需为数字', trigger: 'blur'}
					],
					price: [
						{pattern: /^\d+(\.\d+)?$/, message: '价格需为数字', trigger: 'blur'}
					]
				}
			}
		},
		mounted() {

		},
		methods: {
			//显示
			open(mode='add'){
				this.mode = mode;
				this.visible = true;
				return this;
			},
			//表单提交方法
			submit(){
				this.$refs.dialogForm.validate(async (valid) => {
					if(valid){
						this.isSaveing = true;
						var res = await this.$API.hygl.hyUserSmlz.save.post(this.form);
						this.isSaveing = false;
						if(res.code === 2000){
							this.$emit('success', this.form, this.mode);
							this.visible = false;
							this.$message.success(res.message);
						}else{
							this.$alert(res.message, "提示", {type: 'error'})
						}
					}
				});
			},
			//表单注入数据
			setData(data){
				this.form.hyUserId = data.hyUserId;
				this.form.updateTime = data.updateTime;
				this.form.idNumber = data.idNumber;
				this.form.identityCardName = data.identityCardName;
				this.form.fileType = data.fileType;
				this.form.fileUrl1 = data.fileUrl1;
				this.form.fileUrl2 = data.fileUrl2;
				this.form.fileUrl3 = data.fileUrl3;
				this.form.fileUrl4 = data.fileUrl4;
				this.form.fileUrl5 = data.fileUrl5;
				this.form.shSysUserId = data.shSysUserId;
				this.form.shTime = data.shTime;
				this.form.shState = data.shState;
			}
		}
	}
</script>
<style>
</style>
